<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
  <title>Weight Log</title>
  <script src="http://www.google.com/jsapi?key=ABQIAAAA2_bqInlnPjkYlttmq_L5rRSu5d35DSyUQRyAIDPmvWIeEYU3pRTBSrCfywOc9iyxnRhxAK2kjWBbUg"></script>
  <script src="/static/js/scripts.js" type="text/javascript"></script>
  <script type="text/javascript">
    dojo.addOnLoad(init);
    google.load("visualization", "1", {packages:["linechart"]});
    google.setOnLoadCallback(doQuery);
    function doQuery() {
      var query = new google.visualization.Query('/chart');
      query.send(drawCharts);
    }

    function drawCharts(response) {
      if (response.isError()) {
        err = document.getElementById('chart-error');
        err.innerHTML = "Error creating chart";
        err.style.display = 'inline';
        return;
      }
      var data = response.getDataTable();
      drawChart(data, 'chart', [0, 1]);
    }

    function drawChart(data, div_id, cols) {
      var dataView = new google.visualization.DataView(data);
      dataView.setColumns(cols);
      var div = document.getElementById(div_id);
      var chart = new google.visualization.LineChart(div);
      chart.draw(dataView, { min: 80, max: 110 });
    }
  </script>
  <style type="text/css" media="all">
    @import url(/static/css/style.css);
  </style>
</head>
<body bgcolor="#FFFFFF" text="#000000" link="#0000EE" alink="#FF0000" vlink="#990066">
  <h1 align="center"></h1>

  <form>
    <p><label for="date">Date</label><input type="text" id="date" value="{{ cur_date }}" size="10"><span class="unit">yyyy-mm-dd</span></p>
    <p><label for="weight_kg">Weight</label><input type="text" id="weight_kg"
    value="{{ last_weight }}" size="8"><span class="unit">kg</span></p>
    <p><label for="workout_min">Workout</label><input type="text"
    id="workout_min" value="{{ workout_min }}" size="8"><span class="unit">min</span></p>
    <p><label for="running_km">Distance</label><input type="text"
    id="running_km" value="{{ running_km }}" size="8"><span class="unit">km</span></p>
    <p><label for="sld_cal">SLD</label><input type="text" id="sld_cal" value="{{ sld_cal }}"
      size="8"><span class="unit">kcal</span></p>
    <p class="submit"><input type="submit" id="submit" value="Submit" onClick="addEntry()"></p>
  </form>
  <a href="/list">list</a><br>
  <div id="response">&nbsp;</div>

  <div id="chart-error" display='none'></div>
  <div id="chart" style="width: 800px; height:400px"></div>

  <br/>
  <p class="notes">SLD is the Shangri-La diet</p>
  <p class="notes">If you put both a workout time and the distance it's assumed
  you ran that distance for that period.</p>
</body>
</html>
